package com.lx.oms.controller.controller;

import java.math.BigInteger;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.lx.oms.common.annotation.SysLog;
import com.lx.oms.common.controller.AbstractController;
import com.lx.oms.common.entity.Page;
import com.lx.oms.common.entity.R;
import com.lx.oms.controller.entity.FactoryEntity;
import com.lx.oms.controller.service.FactoryService;

/**
 * 厂名
 *
 * @author houzhong
 * @date 2018年10月24日 下午1:26:13
 */
@RestController
@RequestMapping("/sys/factory")
public class FactoryController extends AbstractController {
	
	@Autowired
	private FactoryService factoryService;
	
	/**
	 * 列表
	 * @param params
	 * @return
	 */
	@RequestMapping("/list")
	public Page<FactoryEntity> list(@RequestBody Map<String, Object> params) {
		return factoryService.listFactory(params);
	}
	
	@RequestMapping("/listFactory")
	public List<FactoryEntity> listByFactory(String categoryId,String categoryTwo,String name) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("categoryId", categoryId);
		params.put("categoryTwo", categoryTwo);
		params.put("name", name);
		return factoryService.listByFactory(params);
	}
	
		
	/**
	 * 新增
	 * @param tFactory
	 * @return
	 */
	@SysLog("新增厂名")
	@RequestMapping("/save")
	public R save(@RequestBody FactoryEntity tFactory) {
		return factoryService.saveFactory(tFactory);
	}
	
	/**
	 * 根据id查询详情
	 * @param id
	 * @return
	 */
	@RequestMapping("/info")
	public R getById(@RequestBody String id) {
		return factoryService.getFactoryById(new BigInteger(id));
	}
	
	/**
	 * 修改
	 * @param tFactory
	 * @return
	 */
	@SysLog("修改厂名")
	@RequestMapping("/update")
	public R update(@RequestBody FactoryEntity tFactory) {
		return factoryService.updateFactory(tFactory);
	}
	
	/**
	 * 删除
	 * @param id
	 * @return
	 */
	@SysLog("删除厂名")
	@RequestMapping("/remove")
	public R batchRemove(@RequestBody String[] id) {
		return factoryService.batchRemove(id);
	}
	
}
